package com.earthquake.monitor_system.utils;

import java.util.ArrayList;

public class Result<T> {
    private int code = status.STATUS_SUCCEED;
    private String msg = "请求成功!";
    private T data = null;

    public Result() {
    }
    public Result( String msg, T data) {
        this.msg = msg;
        this.data = data;
    }
    public Result(T data) {
        this.data = data;
    }
    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static Result success(String msg) {
        return new Result(status.STATUS_SUCCEED,msg,null);
    }
    public static Result success(String msg,Object object) {
        return new Result(status.STATUS_SUCCEED,msg,object);
    }
    public static Result warn(String msg,Object object) {
        return new Result(status.STATUS_WARN,msg,object);
    }
    public static Result error(String msg,Object object) {
        return new Result(status.STATUS_ERROR,msg,object);
    }
    public static Result error(int code,String msg,Object object) {
        return new Result(code,msg,object);
    }

    /**
     * 获取
     * @return code
     */
    public int getCode() {
        return code;
    }

    /**
     * 设置
     * @param code
     */
    public void setCode(int code) {
        this.code = code;
    }

    /**
     * 获取
     * @return msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * 设置
     * @param msg
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 获取
     * @return data
     */
    public T getData() {
        return data;
    }

    /**
     * 设置
     * @param data
     */
    public void setData(T data) {
        this.data = data;
    }

    public String toString() {
        return "results{code = " + code + ", msg = " + msg + ", data = " + data + "}";
    }
}
